﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;


namespace PapaetisNew
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
            
            
           


        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
           
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            
            try
            {
                string OraSql = "SELECT USERCODE FROM TAL_USERS WHERE USERCODE='" + txtUserCode.Text + "'";
                String ConnectionString = PapaetisNew.Properties.Settings.Default.ConnectionString1;
                //.Properties.Settings.Default.kapoOleDB
                //    "Provider=OraOLEDB.Oracle;Data Source=ORCL;Persist Security Info=True;User ID=PAPAETIS;Password=PAPAETIS;Unicode=True";
                OleDbConnection MyConnection = new OleDbConnection(ConnectionString);
                MyConnection.Open();
                OleDbDataAdapter da = new OleDbDataAdapter(OraSql, MyConnection);

                DataSet ds = new DataSet();

                da.Fill(ds);

                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Incorrect User Try Again");
                }
                else
                {
                    MyConnection.Close();
                    this.Hide();
                    frmSupplier NewSup = new frmSupplier();
                    NewSup.Show();
                   
        
                }


                //frmSupplier frmSupplierNew = new frmSupplier();
                //frmSupplierNew.Show();

            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

        }

        private void frmLogin_Load(object sender, EventArgs e)
        {

        }
    }
}
